import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '@/pages/Home'
import Login from '@/pages/Login'
import Register from '@/pages/Register'
import Search from '@/pages/Search'
import NotFound from '@/pages/NotFound'
import enhance from '@/utils'


Vue.use(VueRouter)


// const nativePush = VueRouter.prototype.push
// VueRouter.prototype.push = function(path,success,error=()=>{}){
//     return nativePush.call(this,path,success,error)
// }


// const nativeReplace = VueRouter.prototype.replace
// VueRouter.prototype.replace = function(path,success,error=()=>{}){
//     return nativeReplace.call(this,path,success,error)
// }


// const enhance = function(prop){
//     const nativeFn = VueRouter.prototype[prop];
//     VueRouter.prototype[prop] = function(path,success,error=()=>{}){
//         return nativeFn.call(this,path,success,error)
//     }
// }

enhance("push")

export default new VueRouter({
    mode:'history',
    routes:[
      // 首页
      {
        path:"/",
        component:Home,
        meta:{
            isTypeNav:true,
            isFooterList:true
        }
      },
      {
        path:"/home",
        redirect:"/"
      },
      {
        path:"/login",
        name:"gogogo",
        component:Login,
        meta:{
            isTypeNav:true,
            isFooterList:true
        }
      },
      {
        path:"/register",
        component:Register,
      },
      {
        path:"/search",
        component:Search,
        alias:["/s","/sousuo"],
        meta:{
            isTypeNav:true,
            isFooterList:true
        }
      },
      {
        path:"*",
        component:NotFound
      }
    ]
  })